import {defineStore} from 'pinia'
import {reactive} from 'vue'
import {
    request_get_business_detail
} from '../service/business'

export default defineStore('useBusinessStore', () => {

    const businessDetail = reactive({
        business: {}
    })
    // 前台管理:商家基本信息详情
    const findBusinessId = async (id: number) => {
        let res = await request_get_business_detail(id)
        // console.log(res?.data, "| 商家基本信息");
        res.data.storeVOList = res.data.storeVOList && Array.isArray(res.data.storeVOList) ? res.data.storeVOList : new Array(3).fill('').map((_, idx) => {
            return {
                storeLogo: res?.data?.businessLicense,
                storeName: res?.data?.businessName + '-' + idx
            }
        })
        businessDetail.business = res?.data
    }
    return {
        findBusinessId,
        businessDetail
    }
})